//
//  ACEQuestionsNavTitleView.m
//  ACE
//
//  Created by zhangtao on 2018/8/8.
//  Copyright © 2018年 zt.td. All rights reserved.
//

#import "ACEQuestionsNavTitleView.h"

@implementation ACEQuestionsNavTitleView
{
    UIButton *nameBtn;
    UIImageView *arrowImgV;
}
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor clearColor];
        self.userInteractionEnabled = YES;
        nameBtn = [[UIButton alloc]initWithFrame:CGRectMake(frame.size.width/2-30,0,60,frame.size.height)];;
        [self addSubview:nameBtn];
//        [button mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.mas_equalTo(self);
//            make.height.lessThanOrEqualTo(@60);
//        }];
        [nameBtn setTitle:@"选学校" forState:UIControlStateNormal];
        [nameBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [nameBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        
       arrowImgV = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(nameBtn.frame), frame.size.height/2-2, 10, 5)];
        [self addSubview:arrowImgV];
//        [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerY.mas_equalTo(button);
//            make.left.mas_equalTo(button.mas_right).mas_offset(5);
//            make.width.mas_equalTo(@10);
//            make.height.mas_equalTo(@5);
//        }];
        arrowImgV.image = [UIImage imageNamed:@"下啦"];

    }
    return self;
}

-(void)click:(UIButton *)btn{
//    [btn setTitle:@"加利福尼亚大学" forState:UIControlStateNormal];
//    [btn sizeToFit];
//    btn.center = self.center;
//    arrowImgV.frame = CGRectMake(CGRectGetMaxX(nameBtn.frame), self.center.y, 10, 5);
    
    if (_QuestionsNavtitleCallBack) {
        self.QuestionsNavtitleCallBack();
    }

}

-(void)setTitle:(NSString *)title{
    _title = title;
    [nameBtn setTitle:title forState:UIControlStateNormal];
    [nameBtn sizeToFit];
    nameBtn.center = self.center;
    arrowImgV.frame = CGRectMake(CGRectGetMaxX(nameBtn.frame), self.center.y, 10, 5);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
